<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Example_2.html</title>
</head>
<body>
    <!-- 
        题目2: 将一个字符串里的大小写字符反转一下（小写的转大写，大写的转小写） 
                函数名：strConvert 
                参数：源字符串 
                返回值：大小写反转后的字符串 
                例如：strConvert("HelloWorld") 返回 "hELLOwORLD"
     -->
     第一题:<input type="text" placeholder="HelloWorld">
     <button>点击验证</button>
     <input type="text">
</body>
</html>
<script>
    let oInput = document.getElementsByTagName("input");
    let oBtn = document.getElementsByTagName("button");
    // console.log(oInput, oBtn);

    function strConvert(str) {
        let str1 = "";
        for(let i = 0; i < str.length; i++) {
            if(str[i] >= "a" && str[i] <= "z") {
                str1 += str[i].toUpperCase();
            } else if(str[i] >= "A" && str[i] <= "Z") {
                str1 += str[i].toLowerCase();
            }
        }

        return str1;
    }

   oBtn[0].onclick = function() {
        oInput[1].value = strConvert(oInput[0].value);

    }

</script>